<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>  
<!DOCTYPE html>
<html> 
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
<title>userInfo</title> 
<script type="text/javascript" src="${pageContext.request.contextPath}/static/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/assets/js/jquery.jqprint-0.3.js"></script>
<!-- 实现打印 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/static/assets/js/jquery.browser.js"></script>
<!-- 是jquery.jqprint-0.3.js的补充文件 -->
<script type="text/javascript" src="${pageContext.request.contextPath}/static/assets/js/jquery.qrcode.min.js"></script>
<!-- 利用HTNL5的canvas来实现数据转换二维码 -->
<style type="text/css">
#funll {
	background-repeat: no-repeat;
	background-repeat: repeat-x;
	background-repeat: repeat-y;
	background-attachment: fixed;
	background-position: center;
	background-position: center center;
	width: 100%;
	heght: 100%;
}
</style>
</head> 
<body>  
     姓名： ${userInfo.accountname}
  
<div id="output"
	style="width: 300px; height: 300px; padding: 100px; float: left;">
</div>
<button onclick="printQr()">asdfdasdf</button>
  <script type="text/javascript">
		function printQr() {
			var qrCode = 'asdfsadfa';//${userInfo.accountname};
			if (qrCode != null && qrCode != '') {
				$('#output').empty();
				$('#output').qrcode({
					width : 300,
					height : 300,
					correctLevel : 0,
					text : utf16to8(qrCode)
				});
				$('#output').css('display', 'block');
				$("canvas").attr("id", "erw");
				var canvas = document.getElementById('erw');
				/*var image = new Image();
				var strDataURI = canvas.toDataURL("image/png");
				document.getElementById('myImg').src = strDataURI;*/
				/* $('input').attr("value",""); */
				/*if (!!window.ActiveXObject || "ActiveXObject" in window) {
					$('#myImg').css("width", '200px');
					$('#myImg').css("height", '200px');
					//$("#myImg").jqprint();
				} else {
					//$("#myImg").jqprint();
				}*/
			} else {
				alert('获取数据失败');
			}
		}
		function utf16to8(str) {
			var out, i, len, c;
			out = "";
			len = str.length;
			for (i = 0; i < len; i++) {
				c = str.charCodeAt(i);
				if ((c >= 0x0001) && (c <= 0x007F)) {
					out += str.charAt(i);
				} else if (c > 0x07FF) {
					out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
					out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
					out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
				} else {
					out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
					out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
				}
			}
			return out;
		}
	</script>
</body>  
</html>  